import pandas as pd

if __name__ == "__main__":
    field = "ads"
    train_field_path = "/media/HardDisk_A/Dataset/hw_ctr/train/train_data_{}.csv".format(field)
    test_field_path = "/media/HardDisk_A/Dataset/hw_ctr/train/test_data_{}.csv".format(field)
    if field == "ads":
        train = pd.read_csv(train_field_path, usecols=["user_id"])
        test = pd.read_csv(test_field_path, usecols=["user_id"])
    else:
        train = pd.read_csv(train_field_path, usecols=["u_userId"])
        test = pd.read_csv(test_field_path, usecols=["u_userId"])
    
    and_set = pd.merge(train, test)
    or_set = pd.merge(train, test, how='outer')
    print("{} 用户重合度为： {}".format(field, len(and_set)/len(or_set)))
    